import React, { Component } from 'react';
import { withRouter, Link, Switch, Route, HashRouter as Router } from 'react-router-dom'
import u from '../common.js'


//判断用户是否登录

class AuthRoute extends React.Component{
//   constructor(props){
//     super(props)
//   }
  async componentDidMount(){
    //   alert(this.props.history)
    const pathname = window.location.pathname
    if(pathname ==='/login') {
      return null
    }
    u.userInfo(data=>{
        if(data.msg == '没有登录'){
            this.props.history.push('/login')
        }
    },()=>{
      this.props.history.push('/login')
    })
  }
  render(){
    return null
  }
}

export default withRouter(AuthRoute)